export const fn = (getname1, getvalue1) => {
  var getname = getname1 || ['资金']
  var getvalue = getvalue1 || [0]

  var data = []
  for (var i = 0; i < getname.length; i++) {
    data.push({ name: getname[i], value: getvalue[i] })
  }
  var colorList = [
    {
      type: 'linear',
      colorStops: [
      // !! 在此添加想要的渐变过程色 !!
        { offset: 0, color: '#00B4E1' },
        { offset: 1, color: '#00FCFD' }
      ]
    },
    {
      type: 'linear',
      colorStops: [
      // !! 在此添加想要的渐变过程色 !!
        { offset: 0, color: '#38F8D4' },
        { offset: 1, color: '#43EA80' }
      ]
    },
    {
      type: 'linear',
      colorStops: [
      // !! 在此添加想要的渐变过程色 !!
        { offset: 0, color: '#015EEA' },
        { offset: 1, color: '#00C0FA' }
      ]
    },
    {
      type: 'linear',
      colorStops: [
      // !! 在此添加想要的渐变过程色 !!
        { offset: 0, color: '#5050FF' },
        { offset: 1, color: '#8E79FF' }
      ]
    },
    {
      type: 'linear',
      colorStops: [
      // !! 在此添加想要的渐变过程色 !!
        { offset: 0, color: '#FF5EB1' },
        { offset: 1, color: '#FF986B' }
      ]
    },
    {
      type: 'linear',
      colorStops: [
      // !! 在此添加想要的渐变过程色 !!
        { offset: 0, color: '#9F56CB' },
        { offset: 1, color: '#F988E7' }
      ]
    }
  ]

  const option = {
  // backgroundColor: '#000',
    tooltip: {
      trigger: 'item'
    },
    title: [
      {
        text: '48,368',
        x: 'center',
        y: '20%',
        textStyle: {
          fontSize: 14,
          fontWeight: 'normal',
          color: '#D0FFF2'
        }
      },
      {
        text: '标准化基地',
        x: 'center',
        y: '30%',
        textStyle: {
          fontSize: 16,
          fontWeight: 'normal',
          color: '#D0FFF2'
        }
      }
    ],
    legend: {
    // orient: "vertical",
      show: true,
      y: '58%',
      x: 'center',
      icon: 'rect', // 设置为圆，删除则为矩形
      textStyle: {
        color: '#c0c4cc',
        fontSize: 14,
        lineHeight: 20,
        rich: {
          percent: {
            color: '#fff',
            fontSize: 16
          }
        }
      },
      formatter: function(name) {
        for (var i = 0; i < getname.length; i++) {
          if (name === data[i].name) {
            return '{name|' + name + '}\r\r{rate|' + getvalue[i] + '}'
          }
        }
      }
    },

    series: [
      {
        type: 'pie',
        radius: ['35%', '45%'],
        center: ['50%', '30%'],
        // itemStyle: {
        //   normal: {
        //     color: function(params) {
        //       return colorList[params.dataIndex]
        //     }
        //   }
        // },
        label: {
          show: false,
          position: 'center'
        },
        labelLine: {
          show: false
        },
        data: data
      }
    ]
  }
  return option
}

export default fn()
